package erfgame.core.world.generator.terrain;


import erfgame.core.Operation;
import erfgame.core.SimpleAbstractOperation;
import erfgame.core.world.World;
import erfgame.core.world.WorldGenerationParameters;
import erfgame.core.world.WorldGenerator;
import erfgame.core.world.WorldUpdater;

public class WorldUpdaterToGeneratorAdapter 
	implements WorldGenerator {

	private WorldUpdater updater;
	
	public WorldUpdaterToGeneratorAdapter( WorldUpdater updater ) {
		this.updater = updater;
	}
	
	public Operation<Void, RuntimeException> generate(final World world, final WorldGenerationParameters parameters) {
		return new SimpleAbstractOperation<Void, RuntimeException>(this.updater.getClass().getName()) {

			@Override
			protected Void doPerform() throws RuntimeException {
				// TODO incremental, interleaved updates
				updater.update(world, parameters.getTotalDuration());
				return null;
			}
		};
	}

}
